//
// Created by codex on 2024/7/15.
//
#include "PWM.h"
//模拟PWM生成在main.c定时器回调
pwm_s PWM_S;
void my_pwm_setperiod(uint8_t tag,uint8_t period) //0~2000 50-0  250-180?
{
    if(tag==1)
        PWM_S.pwm1_period=period;
    else if(tag==2)
        PWM_S.pwm2_period=period;
}
void PWM_S_init()
{
    angle_set(1,90);
    angle_set(2,90);
    PWM_S.pwm1_sta=ON;
    PWM_S.pwm2_sta=ON;
}
void angle_set(uint8_t tag,int angle)
{
    if(tag==1&&(angle<60||angle>120))return;
    if(tag==2&&(angle<60||angle>120))return;
    if(tag==1)
    {
        PWM_S.pwm1_period=50+angle*200/180;
    }
    else if(tag==2)
    {
        PWM_S.pwm2_period=50+angle*200/180;
    }
}

